﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DoNet.Common.Utilities;
using Shop.Intermediate;
using Shop.Core;
using Shop.Intermediate.Data;

namespace Shop.WebApp
{
    public partial class WebForm1 : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(Request.Url.ToString());

            PageHelper.RemoveCookies(this.Page);
            
            PageHelper.SetCookie(this.Page, "username", "yuli");

            string user = PageHelper.GetCookie(this.Page, "username");

            Response.Write(user);

            PageHelper.SetCookieDomain(this.Page, "www.alpha.com");

            Response.Write(PageHelper.GetCookieDomain(this.Page,"username"));


            string[] names = new string[] {"hn","bj","sh" };
            string[] values = new string[] {"湖南","上海","北京" };

            PageHelper.DropDownListBind(ddlRegion, names, values,false);

            Response.Write(StringHelper.GetMD5String("yuli"));

            PageHelper.SetSession(this.Page, "pass", "tttttttttt");

            Response.Write(PageHelper.GetSession(this.Page,"pass"));

        }

        protected void WebButton1_Click(object sender, EventArgs e)
        {
            DepartmentCore dpt = new DepartmentCore();
            IDepartment entity = dpt.NewEntity();
            FormHelper<IDepartment>.Instance.UpdateModel(form1, entity);

            Response.Write(entity.Code);
        }

        protected void ddlRegion_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        public static string GetCurrentDateTime(HttpContext context)
        {
            return DateTime.Now.ToString();
        }
    }
}
